package org.jeecg.modules.rooms.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.rooms.Vo.FloorWithBuildingVo;
import org.jeecg.modules.rooms.entity.CesRoomBuildingFloor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
 * <p>
 * 楼栋楼层表 Mapper 接口
 * </p>
 *
 * @author fendo
 * @since 2023-03-06
 */
public interface CesRoomBuildingFloorMapper extends BaseMapper<CesRoomBuildingFloor> {
    @Select("SELECT\n" +
            "\tb2.`name` AS buildingName,\n" +
            "\tb2.id AS buildingId,\n" +
            "\tb1.* \n" +
            "FROM\n" +
            "\tces_room_building_floor b1\n" +
            "\tINNER JOIN ces_room_building_floor b2 ON b1.parent_id <> 0 \n" +
            "\tAND b1.parent_id = b2.id \n" +
            "WHERE\n" +
            "\tb1.hotelId = #{hotelId} \n" +
            "\tAND b1.invalid = 0 ")
    List<FloorWithBuildingVo> buildingFloors(@Param("hotelId") String hotelId);
}
